<style>
    html, body {
        background-color: #FFF !important;
    }

    .modal-body {
        background-color: #fff;
        padding: 15px
    }

    .page-header {
        margin-top: 15px !important;
    }

    .geographic input {
        width: 100px !important;
        float: left;
        margin-right: 15px;
    }
    .config_img{width:45px;height:45px;margin-top:15px;}
</style>


<div class="modal-header">

    <div class="assistant_header">
        <button type="button" class="close" data-dismiss="modal" close="true">
            <span aria-hidden="true">×</span>
        </button>
        <h4 class="modal-title">
            <span class="fa fa-legal"></span>&nbsp;修改导航
        </h4>
    </div>
</div>

<div class="modal-body">



    <form class="form-horizontal layui-form">

        <div class="form-group">
            <label class="col-sm-3 control-label">*导航名称:</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="text" placeholder="导航名称" value="{$detail.text}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">*导航地址:</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" name="pagePath" placeholder="导航地址" value="{$detail.pagePath}">
            </div>
        </div>

        <div class="form-group js_photos">
            <label class="col-sm-3 control-label">导航图标</label>
            <div class="col-sm-8 iconPath">
                <div class="input-group ">
                    <input type="file" name="" class="do_upload" data-val="iconPath"  style="display: none">
                    <input type="text" class="form-control iconPath" name="iconPath" disabled="" value="{$detail.iconPath}" >
                    <input type="hidden" class="form-control iconPath" name="iconPath" value="{$detail.iconPath}" >
                    <span class="group-span-filestyle input-group-btn" tabindex="0">
                                <label class="btn btn-default id_photos" data-original-title="" title="">
                                    <span class="glyphicon glyphicon-folder-open"></span>
                                    上传
                                </label>
                            </span>
                    </span>
                </div>

                {if condition="$detail['iconPath'] eq ''"}
                <img class="config_img" src="/static/images/nopic-107.png" >
                {else/}
                <img class="config_img" src="{$detail.iconPath}" >
                {/if}
            </div>
        </div>

        <div class="form-group js_photos">
            <label class="col-sm-3 control-label">导航选中图标</label>
            <div class="col-sm-8 selectedIconPath">
                <div class="input-group ">
                    <input type="file" name="" class="do_upload" data-val="selectedIconPath"  style="display: none">
                    <input type="text" class="form-control selectedIconPath" name="selectedIconPath" disabled="" value="{$detail.selectedIconPath}" >
                    <input type="hidden" class="form-control selectedIconPath" name="selectedIconPath" value="{$detail.selectedIconPath}" >
                    <span class="group-span-filestyle input-group-btn" tabindex="0">
                                <label class="btn btn-default id_photos" data-original-title="" title="">
                                    <span class="glyphicon glyphicon-folder-open"></span>
                                    上传
                                </label>
                            </span>
                    </span>
                </div>
                {if condition="$detail['selectedIconPath'] eq ''"}
                <img class="config_img" src="/static/images/nopic-107.png" >
                {else/}
                <img class="config_img" src="{$detail.selectedIconPath}" >
                {/if}
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">排序:</label>
            <div class="col-sm-8">
                <input type="number" class="form-control" name="sort" placeholder="排序" value="{$detail.sort}">
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label">*状态:</label>
            <div class="col-sm-8">
                <select name="status" lay-verify="status" lay-filter="status" class="select">
                    {volist name="enable_status" id="vo"}
                    <option value="{$key}" {if condition="$detail['status'] eq $key"} selected {/if} >{$vo}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <input type="hidden" name="id" value="{$detail.id}">
    </form>
</div>
<div class="assistant_button"  style="text-align: right">
    <button type="button" class="layui-btn layui-btn-primary js_quit" close="true">取消</button>
    <button type="button" class="layui-btn js_add" _event="update_manager" data-id="0"  >保存</button>
</div>


<script>
    $(function() {
        $(this).find('.modal-dialog').css({
            'width': '600px'
        });
    });

    $(".id_photos").click(function () {
        $(this).parent().parent().find(".do_upload").click();
    });

    $('.js_photos').on('change','.do_upload',function(){
        var content = $(this).attr("data-val");
        var formData = new FormData();
        var name = $($(this)).val();
        var files = $($(this))[0].files[0];
        formData.append("file", files);
        formData.append("name", name);
        //另外加的参数
        formData.append("act", "PostImg");
        // var index = layer.msg('正在提交中....');

        $.ajax({
            url: "{:URL('common/upload/ad_upload')}",
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            dataType: 'json',
            success:function (res) {
                $("."+content).val(res.path);
                $("."+content).find("img").attr("src",res.path);
            }
            ,error:function (res) {
                alert('错误');
            }
        });
    })

    layui.use(['form', 'layedit', 'tree', 'util','laydate'], function () {
        var form = layui.form
            , layer = layui.layer;
        layui.form.render('select');
        form.render();
    });

</script>

</body>
</html>